package com.fayakeji.ucpaas;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author <a href="mailto:wangruihuano@gmail.com">王瑞环</a>
 * @since 2019-06-13 21:44
 */
@Configuration
@ConditionalOnClass(UcpaasSmsService.class)
@EnableConfigurationProperties(UcpaasProperties.class)
public class UcpaasAutoConfigure {

    @Autowired
    private UcpaasProperties properties;

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(prefix = "ucpaas", havingValue = "true")
    public UcpaasSmsService exampleService() {
        return new UcpaasSmsService(properties);
    }
}
